package com.xbongbong.pro.statistic.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 钻取的方向（上卷和下钻）
 *
 * @author xbongbong
 * @version v1.0
 * @date 2022/9/14 9:16
 * @since v1.0
 */
@Getter
public enum DrillDirEnum {

    /**
     * 上卷
     */
    UP("up", "enum.drillDirEnum.name.up"),

    /**
     * 下钻
     */
    DOWN("down", "enum.drillDirEnum.name.down"),
    ;

    /**
     * 枚举值
     */
    private String alias;

    /**
     * 名称
     */
    private String name;

    DrillDirEnum(String alias, String name) {
        this.alias = alias;
        this.name = name;
    }

    /**
     * 根据alias
     * @param alias
     * @return com.xbongbong.pro.statistic.enums.DrillDirEnum
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static DrillDirEnum getByAlias(String alias){
        for (DrillDirEnum cache : values()) {
            if (Objects.equals(alias, cache.alias)) {
                return cache;
            }
        }
        return null;
    }
    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
